#{extends 'main.html' /}
#{set title:'商家报表' /}
<script type="text/javascript" src="/public/javascripts/echarts.min.js" ></script>
<body>
<div class="page">
    <header class="bar bar-nav">
        <a href="javascript:history.go(-1);" class="icon icon-left pull-left"></a>
        <h1 class="title">商家报表</h1>

    </header>
    <section  class="content money_info scroll_y">
        <div class="money_count">

            <p>时间段：<input id="startTime" name="startTime" type="text" data-toggle='date' value="${startTime}"/> 至
                <input id="endTime" type="text" data-toggle='date' value="${endTime}"/>
                <button type="button" class="button button-fill button-cyan" id="searchBtn">查询</button>
            </p>

        </div>
        <div class="money_list" id="merStatisticsList">

        </div>
    </section>
    <script id="merStatistics_tpl" type="text/html">
        <table>
            <tr>
                <th>名称</th>
                <th>访问量</th>
                <th>销售量</th>
            </tr>

                {{# if(d != null && d.length > 0){ }}
                {{# for(var i = 0 ; i < d.length ; i++){ }}
                    <tr>
                        <td> {{d[i].name}}</td>
                        <td>{{d[i].visitCount != null ? d[i].visitCount : 0}}</td>
                        <td>{{d[i].salesvolumes != null ? d[i].salesvolumes : 0}}</td>
                    </tr>
                {{# } }}
                {{# } }}
            </tr>
        </table>

    </script>
#{include 'footer.html'/}
</div>


<script>
    $(function () {
        $.init();
    });
</script>


<script type="text/javascript">


    var startTime ;
    var endTime ;

    $(function(){
        startTime = $("#startTime").val();
        endTime = $("#endTime").val();
        getType(startTime,endTime);

        $("button[id='searchBtn']").on('click', function () {
            startTime = $("#startTime").val();
            endTime = $("#endTime").val();
            getType(startTime,endTime);

        });
    });
    //获取明细
    function getType(startTime ,endTime) {
        console.log("startTime",startTime)
        if(startTime == null || startTime == '' || startTime == undefined){
            $.alert('请选择开始时间');
            return ;
        }
        if(endTime == null || endTime == '' || endTime == undefined){
            $.alert('请选择 结束时间');
            return ;
        }

        $.getJSON('/statistics/merStatistics',{startTime:startTime , endTime:endTime},function (data) {
            console.log(data.productList);
            var gettpl = document.getElementById('merStatistics_tpl').innerHTML;
            laytpl(gettpl).render(data.productList, function (html) {
                document.getElementById('merStatisticsList').innerHTML = html;
                $("#merStatisticsList").scrollTop(0);

            });

        })
    }
</script>

</body>






